/**
 * Core TypeScript interfaces and types for the Emotion 3D Website
 * Requirements: 3.3, 3.4
 */

// ============================================
// Emotion Types
// ============================================

/**
 * Emotion type enumeration
 */
export enum EmotionType {
  HAPPY = 'happy',
  SAD = 'sad',
  ANXIOUS = 'anxious',
  CALM = 'calm',
  ANGRY = 'angry',
  EXCITED = 'excited',
  CONFUSED = 'confused',
  HOPEFUL = 'hopeful'
}

/**
 * Emotion color mapping
 */
export const EMOTION_COLORS: Record<EmotionType, string> = {
  [EmotionType.HAPPY]: '#FFD700',
  [EmotionType.SAD]: '#4169E1',
  [EmotionType.ANXIOUS]: '#FF6347',
  [EmotionType.CALM]: '#98FB98',
  [EmotionType.ANGRY]: '#DC143C',
  [EmotionType.EXCITED]: '#FF69B4',
  [EmotionType.CONFUSED]: '#9370DB',
  [EmotionType.HOPEFUL]: '#87CEEB'
};

/**
 * Individual emotion item with intensity and visual properties
 */
export interface EmotionItem {
  name: string;
  intensity: number; // 0-100
  color: string;
  icon: string;
}

/**
 * Complete emotion analysis report
 */
export interface EmotionReport {
  emotions: EmotionItem[];
  suggestions: string[];
  summary: string;
  timestamp: Date;
}


// ============================================
// 3D Scene Types
// ============================================

/**
 * 3D Vector representation
 */
export interface Vector3 {
  x: number;
  y: number;
  z: number;
}

/**
 * Floating object type categories
 */
export type FloatingObjectType = 'emoji' | 'food' | 'nature';

/**
 * Floating object in the 3D scene
 */
export interface FloatingObject {
  id: string;
  type: FloatingObjectType;
  modelPath: string;
  position: Vector3;
  rotation: Vector3;
  scale: number;
  animationSpeed: number;
}

/**
 * 3D object configuration for presets
 */
export interface Object3DConfig {
  id: string;
  name: string;
  type: FloatingObjectType;
  geometry: 'sphere' | 'box' | 'custom';
  texture?: string;
  defaultScale: number;
}

// ============================================
// API Request/Response Types
// ============================================

/**
 * Emotion analysis request payload
 */
export interface AnalyzeEmotionRequest {
  text: string;
  language?: string;
}

/**
 * Emotion analysis response payload
 */
export interface AnalyzeEmotionResponse {
  success: boolean;
  report: EmotionReport;
  imagePrompt: string;
  error?: string;
}

/**
 * Image generation request payload
 */
export interface GenerateImageRequest {
  prompt: string;
  style?: string;
}

/**
 * Image generation response payload
 */
export interface GenerateImageResponse {
  success: boolean;
  imageUrl: string;
  error?: string;
}

// ============================================
// Error Types
// ============================================

/**
 * Application error type enumeration
 */
export enum ErrorType {
  NETWORK_ERROR = 'NETWORK_ERROR',
  API_ERROR = 'API_ERROR',
  VALIDATION_ERROR = 'VALIDATION_ERROR',
  RATE_LIMIT_ERROR = 'RATE_LIMIT_ERROR',
  UNKNOWN_ERROR = 'UNKNOWN_ERROR'
}

/**
 * Application error structure
 */
export interface AppError {
  type: ErrorType;
  message: string;
  retryable: boolean;
  details?: unknown;
}

// ============================================
// Component Props Types
// ============================================

/**
 * 3D Scene component props
 */
export interface Scene3DProps {
  objects: FloatingObject[];
  enableParallax: boolean;
  onLoad?: () => void;
}

/**
 * Chat interface component props
 */
export interface ChatInterfaceProps {
  onSubmit: (text: string) => Promise<void>;
  isLoading: boolean;
  placeholder?: string;
}

/**
 * Emotion report display component props
 */
export interface EmotionReportProps {
  report: EmotionReport | null;
  generatedImage: string | null;
  isLoading: boolean;
  onSave?: () => void;
  onShare?: () => void;
}
